package com.rongshu.utils.clickableSpan;


import android.text.TextPaint;
import android.text.style.ClickableSpan;

public abstract class SpanableClickable extends ClickableSpan {
    //标记文字的颜色
    private int txtColor;
    //标记文字的背景
    private int bgColor;
    private boolean mIsPressed;

    public SpanableClickable(int color,int bgColor) {
        this.txtColor = color;
        this.bgColor = bgColor;
    }

    public void setPressed(boolean isSelected) {
        this.mIsPressed = isSelected;
    }

    @Override
    public void updateDrawState(TextPaint ds) {
        super.updateDrawState(ds);
        ds.setColor(txtColor);
        ds.bgColor = mIsPressed ? bgColor : 0x00000000;
        ds.setUnderlineText(false);//不添加下划线
        ds.clearShadowLayer();
    }
}
